package mygame.Input;

import mygame.Collision.FindCollidingVertex;

import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;

public class TerraformHandler {
	private int state;
	private boolean add;
	private Geometry obj;
	private static final float change = 0.01f;
	
	public TerraformHandler() {
		state = 0;
		add = true;
	}
	
	public void start(Geometry geom){
		this.obj = geom;
		this.state = 1;
	}
	
	public void setAdd(){
		this.add = true;		
	}
	
	public void setSubtract(){
		this.add = false;
	}
	
	public void move(Vector3f hitPoint){
		if(state>0){
			if(add)
				FindCollidingVertex.incrVol(this.obj, hitPoint, change);
			else
				FindCollidingVertex.incrVol(this.obj, hitPoint, -change);
		}
	}
	
	public void stop(){
		this.state = 0;
		this.obj = null;
	}
	
	public int getState(){
		return this.state;
	}
}
